
*****************************************************************************************************
*****************************************************************************************************
*****************************************************************************************************
*****************************************************************************************************

*** Generating Graph 01 - Evolution of Brazilian Technical Cooperation expenditures

egen totalyear = total(ct), by(year)

twoway (connected totalyear year in 1/14) in 1/14

***Generating Graph 02 - Main recipients of Brazilian Technical Cooperation

egen totalcountry = total(ct), by(country)

graph bar (mean) totalcountry if totalcountry>3000000 & year==2010, over(country)


**Generating Table 01 - Descriptive Statistics

sum ct ln_ct L.ln_ct bndes ln_bndes ied ln_ied exp ln_exp imp ln_imp fmi bm omc onu esquerda cplp viagem percapita ln_percapita pts polity


** Generating Table 02 - Dynamic Panel Models for Brazilian Technical Cooperation allocation

xtset country year

* Donor's economic interests

* POLS
reg ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp i.year, vce (cluster country)
estimates store m1

* PCSE

xtpcse ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp i.year, het c(ar1)
estimates store m2

*GMM - Arellano Bond BB 

xtabond2 ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp i.year, ////
ivstyle (ln_bndes ln_ied ln_exp ln_imp i.year) /// 
gmmstyle (L.ln_ct) robust
estimates store m3

esttab m1 m2 m3, se r2

*Donor's political interests

*POLS
reg ln_ct L.ln_ct fmi bm omc onu esquerda cplp viagem i.year, vce (cluster country)
estimates store m4

*PCSE
xtpcse ln_ct L.ln_ct fmi bm omc onu esquerda cplp viagem i.year, het c(ar1)
estimates store m5

*GMM - Arellano Bond BB 
xtabond2 ln_ct L.ln_ct fmi bm omc onu esquerda cplp viagem i.year, ////
ivstyle (fmi bm omc onu esquerda cplp viagem i.year) /// 
gmmstyle (L.ln_ct) robust
estimates store m6

esttab m4 m5 m6, se r2


*Recipients' needs

* POLS
reg ln_ct L.ln_ct ln_percapita pts polity i.year, vce (cluster country)
estimates store m7

*PCSE
xtpcse ln_ct L.ln_ct ln_percapita pts polity i.year, het c(ar1)
estimates store m8

**GMM - Arellano Bond BB 

xtabond2 ln_ct L.ln_ct ln_percapita pts polity i.year, ////
ivstyle (ln_percapita pts polity i.year) /// 
gmmstyle (L.ln_ct) robust
estimates store m9

esttab m7 m8 m9, se r2

*Complete models

*POLS
reg ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, vce (cluster country)
estimates store m10

*PCSE
xtpcse ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, het c(ar1)
estimates store m11

*GMM - Arellano Bond BB 
xtabond2 ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, ////
ivstyle (L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year) /// 
gmmstyle (L.ln_ct) robust 
estimates store m12


esttab m10 m11 m12, se r2


********* Generating graph 03 - Marginal effects

*POLS
reg ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, vce (cluster country)
estimates store POLS

*PCSE
xtpcse ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, het c(ar1)
estimates store PCSE

*GMM - Arellano Bond BB 
xtabond2 ln_ct L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year, ////
ivstyle (L.ln_ct ln_bndes ln_ied ln_exp ln_imp fmi bm omc onu esquerda cplp viagem ln_percapita pts polity i.year) /// 
gmmstyle (L.ln_ct) robust 
estimates store GMM


coefplot  (POLS, label(POLS)) (PCSE, label(PCSE)) (GMM, label(GMM)), drop(_cons 2000.year 2001.year 2002.year 2003.year 2004.year 2005.year 2006.year 2007.year 2008.year 2009.year 2010.year 2011.year 2012.year 2013.year 2014.year 2015.year 2016.year 2017.year) yline(0) vertical bycoefs byopts(yrescale) nolabel
